package com.chapp.lastFmWs.parser;

import java.util.ArrayList;
import java.util.List;

public class SearchResponse<T> {
	protected boolean statusOk;
	protected String error;
	protected String query;
	protected int totalResults;

	protected List<T> searchList;

	@SuppressWarnings("unchecked")
	public void addSearchedItem(Object o) {
		if (searchList == null) {
			initListArtists();
		}
		searchList.add((T) o);
	}

	private void initListArtists() {
		searchList = new ArrayList<T>();
	}

	@Override
	public String toString() {
		if (this.statusOk) {
			return getClass().getName() + " Response -->" + statusOk + " "
					+ query + " " + totalResults;
		} else {
			return getClass().getName() + " Error --> " + this.error;
		}
	}

	public List<T> getSearchList() {
		return searchList;
	}

	public boolean isStatusOk() {
		return statusOk;
	}

	public void setStatusOk(boolean statusOk) {
		this.statusOk = statusOk;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public int getTotalResults() {
		return totalResults;
	}

	public void setTotalResults(int totalResults) {
		this.totalResults = totalResults;
	}

}
